package com.rjwh.dingdong.client.network;

import com.rjwh.dingdong.client.application.MyApplication;
import com.rjwh.dingdong.client.constant.LocalConstant;
import com.rjwh.dingdong.client.constant.NetConstant;

import java.util.HashMap;
import java.util.Map;

/**
 * 请求操作
 *
 * @author 王博扬
 * @ClassName ApiResquest
 * @Description TODO(这里用一句话描述这个类的作用)
 * @date 2015-11-19 上午10:36:53
 * @history 1.YYYY-MM-DD author: description:
 */
public class ApiRequest {

    /**
     * 用户登陆
     *
     * @param @param account
     * @param @param password
     * @param @param callBack
     * @return void
     * @throws
     * @Title: doLogin
     * @Description: TODO(这里用一句话描述这个方法的作用)
     * @history 1.YYYY-MM-DD author: description:
     */
    public static void doLogin(String account, String password, HttpWebServiceCallBack callBack) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("account", account);
        params.put("pwd", password);
        HttpWebService.getDataFromServer(NetConstant.SYSLOGIN, params, true, callBack);
    }

    /**
     * 发帖
     *
     * @param @param modularid 模块id
     * @param @param title 标题
     * @param @param content 内容(文字和图片)
     * @param @param attachids 图片id
     * @param @param tagids 标签id
     * @param @param address 定位地址
     * @param @param callBack 回调接口
     * @return void
     * @throws
     * @Title: doPublishTopic
     * @Description: TODO(这里用一句话描述这个方法的作用)
     * @history 1.YYYY-MM-DD author: description:
     */
    public static void doPublishTopic(String modularid, String title, String content, String attachids, String tagids, String address, HttpWebServiceCallBack callBack) {
        Map<String, String> publishTopicParams = new HashMap<String, String>();
        publishTopicParams.put("userid", MyApplication.spUtil.getStrPreferenceByParamName(MyApplication.app, LocalConstant.SP_USERID));
        publishTopicParams.put("username", MyApplication.spUtil.getStrPreferenceByParamName(MyApplication.app, LocalConstant.SP_USERNAME));
        publishTopicParams.put("modularid", modularid);
        publishTopicParams.put("title", title);
        publishTopicParams.put("content", content);
        publishTopicParams.put("attachids", attachids);
        publishTopicParams.put("tagids", tagids);
        publishTopicParams.put("address", address);
        HttpWebService.getDataFromServer(NetConstant.COMMUNITY_PUBLISHTOPIC, publishTopicParams, true, callBack);
    }

    /**
     * 回复帖子
     *
     * @param @param modularid
     * @param @param topicid
     * @param @param ptid
     * @param @param replyid
     * @param @param title
     * @param @param content
     * @param @param attachids
     * @param @param address
     * @param @param callBack
     * @return void
     * @throws
     * @Title: doPublishReply
     * @Description: TODO(这里用一句话描述这个方法的作用)
     * @history 1.YYYY-MM-DD author: description:
     */
    public static void doPublishReply(String modularid, String topicid, String parentid, String replyid, String title, String content, String attachids, String address, HttpWebServiceCallBack callBack) {
        Map<String, String> publishReplyParams = new HashMap<String, String>();
        publishReplyParams.put("userid", MyApplication.spUtil.getStrPreferenceByParamName(MyApplication.app, LocalConstant.SP_USERID));
        publishReplyParams.put("username", MyApplication.spUtil.getStrPreferenceByParamName(MyApplication.app, LocalConstant.SP_USERNAME));
        publishReplyParams.put("modularid", modularid);
        publishReplyParams.put("topicid", topicid);
        publishReplyParams.put("parentid", parentid);
        publishReplyParams.put("replyid", replyid);
        publishReplyParams.put("title", title);
        publishReplyParams.put("content", content);
        publishReplyParams.put("attachids", attachids);
        publishReplyParams.put("address", address);
        HttpWebService.getDataFromServer(NetConstant.COMMUNITY_PUBLISHREPLY, publishReplyParams, true, callBack);
    }

    /**
     * 社区-帖子点赞/收藏操作
     *
     * @param @param userid
     * @param @param topicid    帖子id
     * @param @param objectid   此值默认传0
     * @param @param actionid   动作类型 1:点赞 2:收藏
     * @param @param operateid  操作类型  1 点赞、收藏 2:取消点赞、收藏
     * @param @param callBack
     * @return void
     * @throws
     * @Title: doAddFavorOrZan
     * @Description: TODO(这里用一句话描述这个方法的作用)
     * @history 1.YYYY-MM-DD author: description:
     */
    public static void doAddFavorOrZan(String topicid, String objectid, String actionid, String operateid, HttpWebServiceCallBack callBack) {
        Map<String, String> addFavorOrZanParams = new HashMap<String, String>();
        addFavorOrZanParams.put("userid", MyApplication.spUtil.getStrPreferenceByParamName(MyApplication.app, LocalConstant.SP_USERID));
        addFavorOrZanParams.put("topicid", topicid);
        addFavorOrZanParams.put("objectid", objectid);
        addFavorOrZanParams.put("actionid", actionid);
        addFavorOrZanParams.put("operateid", operateid);
        HttpWebService.getDataFromServer(NetConstant.COMMUNITY_ADDTOFAVORITEGOOD, addFavorOrZanParams, true, callBack);
    }

    /**
     * 意见反馈
     *
     * @param content
     * @param callBack
     */
    public static void doLeaveMessage(String content, HttpWebServiceCallBack callBack) {
        Map<String, String> params = new HashMap<>();
        params.put("content", content);
        HttpWebService.getDataFromServer(NetConstant.LEAVEMESSAGE, params, true, callBack);
    }

    /**
     * 验证宝宝合法性
     *
     * @param childid
     * @param callBack
     */
    public static void addBabyCheck(String childid, HttpWebServiceCallBack callBack) {
        Map<String, String> params = new HashMap<>();
        params.put("childid", childid);
        HttpWebService.getDataFromServer(NetConstant.ADDBABYCHECK, params, true, callBack);
    }

    /**
     * 添加宝宝
     *
     * @param childid
     * @param childname
     * @param birthday
     * @param sex
     * @param title
     * @param callBack
     */
    public static void addBaby(String childid, String childname, String birthday, String sex, String title, HttpWebServiceCallBack callBack) {
        Map<String, String> params = new HashMap<>();
        params.put("childid", childid);
        params.put("childname", childname);
        params.put("birthday", birthday);
        params.put("sex", sex);
        params.put("title", title);
        HttpWebService.getDataFromServer(NetConstant.ADDBABY, params, true, callBack);
    }

    /**
     * 删除宝宝
     *
     * @param childid
     * @param callBack
     */
    public static void delBaby(String childid, HttpWebServiceCallBack callBack) {
        Map<String, String> params = new HashMap<>();
        params.put("childid", childid);
        HttpWebService.getDataFromServer(NetConstant.DELBABY, params, true, callBack);
    }

    /**
     * 修改用户资料
     *
     * @param value
     * @param type
     * @param callBack
     */
    public static void saveUserData(String value, String type, HttpWebServiceCallBack callBack) {
        Map<String, String> issueParams = new HashMap<String, String>();
        issueParams.put("value", value);
        issueParams.put("type", type);
        HttpWebService.getDataFromServer(NetConstant.SAVEPARENTDATA, issueParams, true, callBack);
    }

    /**
     * 修改宝宝资料
     *
     * @param value
     * @param type
     * @param callBack
     */
    public static void saveBabyData(String value, String type, HttpWebServiceCallBack callBack) {
        Map<String, String> issueParams = new HashMap<String, String>();
        issueParams.put("value", value);
        issueParams.put("type", type);
        HttpWebService.getDataFromServer(NetConstant.SAVEBABYDATA, issueParams, true, callBack);
    }

    /**
     * 绑定推送
     */
    public static void pushBinding(String clientid, HttpWebServiceCallBack callBack) {
        Map<String, String> issueParams = new HashMap<>();
        issueParams.put("clientid", clientid);
        HttpWebService.getDataFromServer(NetConstant.PUSHBINDING, issueParams, true, callBack);
    }

    /**
     * 绑定推送
     */
    public static void pushBindingForAppId(String appid,String clientid, HttpWebServiceCallBack callBack) {
        Map<String, String> issueParams = new HashMap<>();
        issueParams.put("appid", appid);
        issueParams.put("clientid", clientid);
        HttpWebService.getDataFromServer(NetConstant.PUSHBINDINGFORAPPID, issueParams, true, callBack);
    }
}
